/**
 * File:		RequestHandler.java
 * Project:		Virtual Advisor
 * Module:		Data Management
 * Author:		Rotem Ganel
 * Created:		May 10, 2011
 * Updated:		May 10, 2011
 * Version:		1 (in progress)
 */
package server.serverApp;

import java.io.IOException;
import java.util.ArrayList;

import clientApp.Course;
import clientApp.Degree;
import clientApp.User;
import clientSocket.Request;
import server.dataManagement.RequestInterpreter;
import server.dataManagement.exceptions.RepositoryFilenamesNotSetException;

public class RequestHandler {
	public static Object handle(Request request) throws IOException, RepositoryFilenamesNotSetException {
		switch (request.type) {
		case retrieveCatalog:
			return RequestInterpreter.retrieveCatalog();
		case getDegrees:
			return RequestInterpreter.getDegrees();
		case getUserType:
			return RequestInterpreter.getUserType(request.parameters[0]);
		case findUser:
			return RequestInterpreter.findUser(request.parameters[0], request.parameters[1]);
		case getUsers:
			return RequestInterpreter.getAllTheFuckinUsers();
		case saveUsers:
			RequestInterpreter.haxx((ArrayList<User>)request.object);
			return null;
		case saveCatalog:
			RequestInterpreter.storeCatalog((ArrayList<Course>)request.object);
			return null;
		case saveCurriculum:
			RequestInterpreter.storeCurriculum((ArrayList<Degree>)request.object);
			return null;
		}
		return null;
	}
}
